$(function (){
	$('#card').datagrid(
			{
				rownumbers : true,
				singleSelect : true,
				method : 'post',
				fitColumns : true,
				singleSelect:false,
				fit:true,
				columns : [ [
					    {field:'',title:'',checkbox:true},
						{field : 'detailsId',width :'10%',align : 'left',title : '编号',editor:'textbox'},
						{field:'empId',title:'员工编号', width:'8%',
							formatter: function(value,row,index){
								if (row.emp){
									return row.emp.empId;
								} else {
									return "";
								}
							}},
						{field : 'cardTime',width : '20%',align : 'center',title : '打卡时间'},
						{field : 'reason',width : '10%',align : 'center',title : '原因'},
						{field : 'whetherValid',width : '10%',align : 'center',title : '是否有效'},
					 ] ],
				});
})
		$("#saveCard").bind("click",function(){
			var rows = $('#card').datagrid('getSelections');
			var withcards = [];
			for(var i = 0; i < rows.length; i++){
				withcards.push(rows[i])
			}
			var huo_rowData = JSON.stringify(withcards);
			alert(huo_rowData);
			$.ajax({
				url : "../card/addCheckcard",
				data : {"jsondata" : huo_rowData},
				success : function(e) {
					if (e == "ok") {
		               alert("保存成功");
					}
				}
			});
})